#!/usr/bin/env python

from flask import Flask, request, session, g, redirect, url_for, abort, \
        render_template, flash
from models import app, db, Node, dump_tree
from csv_import import import_dir

app.debug = True

@app.route('/')
def index():
    db.create_all()
    root = Node(u"English")
    import_dir('./data', root)
    db.session.add(root)
    db.session.commit()
    return render_template('index.html')
    
@app.route('/list')
def list():
    root = db.session.query(Node).\
        filter(Node.name == u"English").\
        first()
    return dump_tree(root)
    
if __name__ == '__main__':
    app.run()
